from predict_cmd import main
import os
from kaggle_find_best_epoch import find_best_epoch_v9, find_best_epoch_v15


epoches = [
    int(find_best_epoch_v9('../../data/tmp_fp_reduction/kaggle_log/cddv9_valid{i}.log'.format(i=i))) for i in range(5)
]
print(epoches)
cddnames = ['spie_candidates_v4.pkl', 'kaggle_testset_candidates_v4.pkl', 'kaggle_beni_candidates_v4.pkl']
cddvolname = 'lidc_kaggle_candidates_v9.hdf5'
name = 'cddv9_fold{i}_{cddname}'
for cddname in cddnames:
    for i in [0, 1, 2, 3, 4]:
        main([name.format(i=i, cddname=os.path.splitext(cddname)[0]),
              '--candidate_file', '../../data/tmp_fp_reduction/'+cddname,
              '--candidate_vol_file', '../../data/tmp_fp_reduction/'+cddvolname,
              '--batchsize', '32',
              '--loadfrom', '../../data/tmp_fp_reduction/kaggle_models/cddv9_valid{i}/epoch-{epoch:04d}.hdf5'.format(i=i, epoch=epoches[i])])


epoches = [
    int(find_best_epoch_v15('../../data/tmp_fp_reduction/kaggle_log/cddv15_v2_valid{i}.log'.format(i=i))) for i in range(4)
]
print(epoches)
cddnames = ['kaggle_beni_candidates_v10.pkl', 'kaggle_testset_candidates_v10.pkl', 'spie_candidates_v10.pkl']
cddvolname = 'lidc_kaggle_candidates_v15.hdf5'
name = 'cddv15_v2_fold{i}_{cddname}'
for cddname in cddnames:
    for i in [0, 1, 2, 3]:
        main([name.format(i=i, cddname=os.path.splitext(cddname)[0]),
              '--candidate_file', '../../data/tmp_fp_reduction/'+cddname,
              '--candidate_vol_file', '../../data/tmp_fp_reduction/'+cddvolname,
              '--batchsize', '32',
              '--loadfrom', '../../data/tmp_fp_reduction/kaggle_models/cddv15_v2_valid{i}/epoch-{epoch:04d}.hdf5'.format(i=i, epoch=epoches[i])])

